package blog.service;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import blog.entity.Comment;
import blog.mapper.CommentMapper;

@Service
public class CommentServiceImpl  implements CommentService{
	@Resource 
	private CommentMapper commentMapper;
	/**
	 * 统计评论总数
	 */
	public Integer countComment() {
		return commentMapper.countComment();
	}

	 /**
     * 查询最新评论列表(用于前台右侧边栏)
     */
    public List<Comment> listRecentComment(Integer limit) {
    	return commentMapper.listRecentComment(limit);
    }
    
    /**
     * 得到某个文章对应的所有评论列表
     */
    public List<Comment> listCommentByArticleId(Integer articleId) {
        return commentMapper.listCommentByArticleId(articleId);
    }

	/**
	 * 给文章添加评论
	 */
	public void addComment(Comment comment) {
		  commentMapper.addComment(comment);
	}
}
